﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using HienThi;

namespace DAO
{
    public class BaoDiemThanhVienDAO
    {
        public List<ThanhVien> LayBangThanhVien()
        {
            SqlConnection conn = DataProvider.ConnectDB();
            string sqlStr = "select * from ThanhVien";
            SqlCommand cmd = new SqlCommand(sqlStr, conn);
            SqlDataReader dr = cmd.ExecuteReader();
            List<ThanhVien> kq = new List<ThanhVien>();
            while (dr.Read())
            {
                ThanhVien temp = new ThanhVien();
                temp.MaTV = dr["MaTV"].ToString();
                temp.TenTV = dr["TenTV"].ToString();
                temp.NgaySinh =DateTime.Parse(dr["NgaySinh"].ToString());
                temp.SDT = "";
                temp.DiaChi = "";
                temp.CV = int.Parse(dr["CV"].ToString());
                kq.Add(temp);
            }
            return kq;
        }
        public int LayCV(string matv)
        {
            SqlConnection conn = DataProvider.ConnectDB();
            string sqlStr = "select CV from ThanhVien where MaTV =@matv ";
            SqlCommand cmd = new SqlCommand(sqlStr, conn);
            SqlParameter pmatv = new SqlParameter("@matv", matv);
            cmd.Parameters.Add(pmatv);
            SqlDataReader dr = cmd.ExecuteReader();
            int kq = 0;
            if (dr.Read())
                kq = int.Parse(dr["CV"].ToString());
            return kq;
        }
    }
}
